<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
// [js] 写一个方法随机生成指定位数的字符串

// function getRandomString (length) {
//   let str = Math.random().toString(36).substr(2)
//   if (str.length >= length) {
// 	return str.substr(0, length)
//   }
//   str += getRandomString(length - str.length)
//   return str
// }
// console.log(getRandomString());
const randomStr = (length = 6) => {
  return Math.random().toString(36).slice(-length)
}
console.log(randomStr);
</script>
</html>